package ai.yue.open.service.cd.service;

import ai.yue.library.base.convert.Convert;
import ai.yue.library.base.view.R;
import ai.yue.library.base.view.Result;
import ai.yue.library.web.util.ServletUtils;
import ai.yue.open.service.cd.entity.ConfNotify;
import ai.yue.open.service.cd.ipo.ConfNotifyIPO;
import ai.yue.open.service.cd.mapper.ConfNotifyMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 配置-通知
 *
 * @author yl-yue
 * @since  2023/2/7
 */
@Service
public class ConfNotifyService extends ServiceImpl<ConfNotifyMapper, ConfNotify> {

    public Result<?> insert(ConfNotifyIPO confNotifyIPO) {
        boolean save = save(Convert.toJavaBean(confNotifyIPO, ConfNotify.class));
        return R.success(save);
    }

    public Result<?> deleteById(Long id) {
        return R.success(removeById(id));
    }

    public Result<?> deleteByIds(List<Long> ids) {
        return R.success(removeByIds(ids));
    }

    public Result<?> updateById(ConfNotifyIPO confNotifyIPO) {
        return R.success(updateById(Convert.toJavaBean(confNotifyIPO, ConfNotify.class)));
    }

    public Result<?> page() {
        PageHelper.startPage(ServletUtils.getRequest());
        List<ConfNotify> list = list();
        return R.success(PageInfo.of(list));
    }

    public Result<?> listAll() {
        return R.success(list());
    }

}
